#ifndef CPP_MYWIDGET_H
#define CPP_MYWIDGET_H

#include <vector>
#include "QtWidgets/QWidget"
#include "QtWidgets/QApplication"
#include "QtWidgets/QLabel"
#include "QtWidgets/QPushButton"
#include "QtWidgets/QVBoxLayout"
#include "QtWidgets/QHBoxLayout"
#include "QtWidgets/QStackedWidget"
#include "QtWidgets/QListWidget"
#include "QtWidgets/QFileDialog"
#include "QtCore/QEventLoop"
#include "QtCore/QDebug"
#include "QtCore/QJsonDocument"
#include "QtCore/QJsonObject"
#include "QtCore/QBuffer"
#include "QtCore/QFile"
#include "QtCore/QJsonArray"
#include "QtGui/QImage"
#include "QtGui/QPixmap"
#include "QtNetwork/QNetworkAccessManager"
#include "QtNetwork/QNetworkRequest"
#include "QtNetwork/QNetworkReply"

class MyWidget : public QWidget {
    Q_OBJECT
public:
    MyWidget(QWidget *parent = nullptr);

private slots:
    void ImageRecognition();

    void ShowRecognitionResult();

private:
    QJsonDocument GetImageRecognitionResult();

    QByteArray GetToken();

    QString ImageToBase64(const QString& imagePath);

    std::vector<QString> ParseItemList(const QJsonArray& itemArray);
    std::vector<QString> ParseJson(const QJsonDocument& response);

private:
    QPushButton *m_imageRecognitionButton = nullptr;
    QWidget *m_menuWidget = nullptr;
    QWidget *m_imageWidget = nullptr;
    QListWidget *m_recogWidget = nullptr;
    QStackedWidget *m_stackWidget = nullptr;
    QLabel *m_menuTitle = nullptr;
    QLabel *m_image = nullptr;
    QLabel *m_imageText = nullptr;
    QVBoxLayout *m_imageLayout = nullptr;
    QVBoxLayout *m_menuButtonLayout = nullptr;
    QString m_fileName;
    QByteArray m_token;
};

#endif // CPP_MYWIDGET_H